export default {
    namespaced: true,
    state: {
        personList: [{ name: '张三', id: '001' }],

    },
    mutations: {
        ADDPERSON(state, value) {
            state.personList.unshift(value)
        }
    },
    actions: {
        addPersonWang(context, value) {
            if (value.name.indexOf('王') === 0) {
                context.commit('ADDPERSON', value)
            } else {
                alert('必须王')
            }
        }

    },
    getters: {
        firstPersonName(state) {
            return state.personList[0].name
        }
    }
}